/**
 * 
 */
package com.base.myproject.client.ui.celleditor;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;

/**
 * 辅助录入工厂
 * @author zgw
 *2009-11-13 上午08:01:57
 * javazgw@gmail.com
 */
public class CellEditorFactory {

	
	public CellEditor getMethodCellEditor()
	{
		 final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
		    combo.setForceSelection(true);  
		    combo.setTriggerAction(TriggerAction.ALL);  
		    combo.add("指定");  
		    combo.add("轮牌");  

		  
		    CellEditor editor = new CellEditor(combo) {  
		      @Override  
		      public Object preProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return combo.findModel(value.toString());  
		      }  
		  
		      @Override  
		      public Object postProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return ((ModelData) value).get("value");  
		      }  
		    };  
		    
		  return editor;  
	}
	
	/**
	 * 年的选择，form
	 * @return
	 */
	 public SimpleComboBox<String> getYEARCombobox()
	{
		final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
	    //combo.setForceSelection(true);  
	    combo.setTriggerAction(TriggerAction.ALL);  
	    combo.add("2009");  
	    combo.add("2010");  
	    combo.add("2011");  
	    combo.add("2012");
	    combo.add("2013");  
	    combo.add("2014");
	    combo.add("2015");  
	    combo.add("2016");
	    combo.add("2017");  
	    combo.add("2018");
	    combo.add("2019");  
	    combo.add("2020");
	    combo.add("2021");  
	    combo.add("2022");
	    combo.add("2023");  
	    combo.add("2024");
	    combo.add("2025");  
	    combo.add("2026");
	    return combo;
	}
	/**
	 * 年的选择 grid
	 * @return
	 */
	public CellEditor getYEAREditor()
	{
		 
		
		    CellEditor editor = new CellEditor(getYEARCombobox()) {  
		      @Override  
		      public Object preProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return getYEARCombobox().findModel(value.toString());  
		      }  
		  
		      @Override  
		      public Object postProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return ((ModelData) value).get("value");  
		      }  
		    };  
		    
		  return editor;  
	}
	
	
	/**
	 * 月的选择，form
	 * @return
	 */
	 public SimpleComboBox<String> getMONTHCombobox()
	{
		final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
	    combo.setForceSelection(true);  
	    combo.setTriggerAction(TriggerAction.ALL);  
	    combo.add("1");  
	    combo.add("2");  
	    combo.add("3");  
	    combo.add("4");
	    combo.add("5");  
	    combo.add("6");
	    combo.add("7");  
	    combo.add("8");
	    combo.add("9");  
	    combo.add("10");
	    combo.add("11");  
	    combo.add("12");
	
	    return combo;
	}
	/**
	 * 月的选择 grid
	 * @return
	 */
	public CellEditor getMONTHEditor()
	{
		 
		
		    CellEditor editor = new CellEditor(getMONTHCombobox()) {  
		      @Override  
		      public Object preProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return getMONTHCombobox().findModel(value.toString());  
		      }  
		  
		      @Override  
		      public Object postProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return ((ModelData) value).get("value");  
		      }  
		    };  
		    
		  return editor;  
	}
	
	/**
	 * 考核类型
	 * @return
	 */
	public CellEditor getassessCellEditor()
	{
		 final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
		    combo.setForceSelection(true);  
		    combo.setTriggerAction(TriggerAction.ALL);  
		    combo.add("应收比例");  
		    combo.add("实收比例");  
		    combo.add("固定金额"); 
		  
		    CellEditor editor = new CellEditor(combo) {  
		      @Override  
		      public Object preProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return combo.findModel(value.toString());  
		      }  
		  
		      @Override  
		      public Object postProcessValue(Object value) {  
		        if (value == null) {  
		          return value;  
		        }  
		        return ((ModelData) value).get("value");  
		      }  
		    };  
		    
		  return editor;  
	}
}
